import { defineStore } from 'pinia'
import { getUserInfor } from '@/api/userInfor.js'
export const userUserInfor = defineStore('userInfor',{
	state:()=>{
		return {
			id:"",
			imageUrl:"",
			name:"",
			sex:"",
			department:"",
			identity:"",
			account:"",
			email:""
		}
	},
	actions:{
		async userInfor(id){
			const res = await getUserInfor(id)
			console .log(res,333)
			this.imageUrl = res.data[0].image_url;
			this.name = res.data[0].name;
			this.sex = res.data[0].sex;
			this.department = res.data[0].department;
			this.identity = res.data[0].identity;
			this.account = res.data[0].account;
			this.email = res.data[0].email;
			this.id = res.data[0].id;
		}
	}
},{
	persist:{
		// 存储全部数据
		enabled:true,
		// 关键字
		key:'userInfor',
		// 存储方式
		storage:localStorage,
	}
})